package com.ciccwm.log.kafka;

import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.kafka.core.KafkaTemplate;

/**
 * Kafka链路追踪自动配置类.
 * 用于配置Kafka生产者和消费者的链路追踪拦截器.
 */
@Configuration
@ConditionalOnClass(KafkaTemplate.class)
public class KafkaTraceIdAutoConfiguration {

    /**
     * 配置Kafka生产者链路追踪拦截器.
     *
     * @return 生产者拦截器实例
     */
    @Bean
    public TraceIdProducerInterceptor<?, ?> traceIdProducerInterceptor() {
        return new TraceIdProducerInterceptor<>();
    }

    /**
     * 配置Kafka消费者链路追踪拦截器.
     *
     * @return 消费者拦截器实例
     */
    @Bean
    public TraceIdConsumerInterceptor<?, ?> traceIdConsumerInterceptor() {
        return new TraceIdConsumerInterceptor<>();
    }
} 
